package utils;

import java.util.Arrays;
import java.util.List;

import dtos.TechresourceDTO;

public class Vals {
	public TechresourceDTO res;

	public TechresourceDTO getRes() {
		return res;
	}

	public void setRes(TechresourceDTO res) {
		this.res = res;
	}

	private Integer valPages;
	private Integer valBlack;
	private Integer valCyan;
	private Integer valMagent;
	private Integer valYellow;
	private boolean zero;
	private boolean allzero;

	public Vals(TechresourceDTO res) {
		this.res = res;
		this.getValues(res);
	}

	public Integer getValPages() {
		return valPages;
	}

	public void setValPages(Integer valPages) {
		this.valPages = valPages;
	}

	public Integer getValBlack() {
		return valBlack;
	}

	public void setValBlack(Integer valBlack) {
		this.valBlack = valBlack;
	}

	public Integer getValCyan() {
		return valCyan;
	}

	public void setValCyan(Integer valCyan) {
		this.valCyan = valCyan;
	}

	public Integer getValMagent() {
		return valMagent;
	}

	public void setValMagent(Integer valMagent) {
		this.valMagent = valMagent;
	}

	public Integer getValYellow() {
		return valYellow;
	}

	public void setValYellow(Integer valYellow) {
		this.valYellow = valYellow;
	}

	public void getValues(TechresourceDTO res) {
		String status = res.getStatus();
		if (!status.equals("Not Working") && !status.equals("Working")) {
			List<String> stringList = Arrays.asList(status.split(","));
			valBlack = Integer.parseInt(stringList.get(0));
			valCyan = Integer.parseInt(stringList.get(1).substring(1,
					stringList.get(1).length()));
			valMagent = Integer.parseInt(stringList.get(2).substring(1,
					stringList.get(2).length()));
			valYellow = Integer.parseInt(stringList.get(3).substring(1,
					stringList.get(3).length()));
			valPages = Integer.parseInt(stringList.get(4).substring(1,
					stringList.get(4).length()));
			if(valBlack*valCyan*valMagent*valYellow*valYellow*valPages==0)
				zero=true;
			else
				zero=false;
			if(valBlack==0 && valCyan==0 && valMagent==0 && valYellow==0 && valPages==0)
				allzero=true;
			else
				allzero=false;

		} else {

			valBlack = 0;
			valCyan = 0;
			valMagent = 0;
			valYellow = 0;
			valPages = 0;
			zero=false;
			allzero=true;
		}
	}

	public boolean isZero() {
		return zero;
	}

	public void setZero(boolean zero) {
		this.zero = zero;
	}

	public boolean isAllzero() {
		return allzero;
	}

	public void setAllzero(boolean allzero) {
		this.allzero = allzero;
	}
}
